layui.use(['layer', 'form', 'table', 'admin', 'ax', 'func', 'upload', 'laydate'], function () {
    var $ = layui.$;
    var layer = layui.layer;
    var form = layui.form;
    var table = layui.table;
    var $ax = layui.ax;
    var admin = layui.admin;
    var func = layui.func;
    var upload = layui.upload;
    var laydate = layui.laydate;

    /**
     * 系统管理--消息管理
     */
    var Notice = {
        tableId: "noticeTable"    //表格id
    };

    Notice.initColumn = function () {
        return [[
            {type: 'numbers',align:'center', title: '序号',width: 60},
            {field: 'id', align: "center", hide: true, sort: false, title: 'id'},
            {field: 'yaoma', align: "left", sort: false, title: '妖码',width: 150},
            {field: 'name', align: "left", sort: false, title: '店名'},
        ]];
    };

    /**
     * 点击清空按钮
     */
    Notice.reset = function () {
        $('input').val('');
        $("#name").val('');
        form.render();
    };

    /**
     * 点击查询按钮
     */
    Notice.search = function () {
        var queryData = {};
        queryData['name'] = $("#name").val();
        table.reload(Notice.tableId, {
            where: queryData, page: {curr: 1}
        });
    };


    // 清空按钮点击事件
    $('#btnReset').click(function () {
        Notice.reset();
    });

    // 搜索按钮点击事件
    $('#btnSearch').click(function () {
        Notice.search();
    });


    // 渲染表格
    var tableResult = table.render({
        elem: "#" + Notice.tableId,
        url: Feng.ctxPath + '/project/syShopList',
        page: true,
        cellMinWidth: 100,
        limit: 20,
        height: "full-59",
        cols: Notice.initColumn()
    });


    // 工具条点击事件
    table.on('tool(' + Notice.tableId + ')', function (obj) {
        var data = obj.data;
        var layEvent = obj.event;
        if (layEvent === 'edit') {
            Notice.onEditNotice(data);
        } else if (layEvent === 'confirm') {
            Notice.onViewNotice(data);
        }
    });
});